using System;
using System.Collections.Generic;
using System.Text;

namespace PerlinNoise.Interpolator
{
    public class CubicInterpolator : AbstractInterpolator
    {
        public override int StartPointIndex { get { return -1; } }
        public override uint PointsNumber { get { return 4; } }

        public override double interpolate(double[] values, double frac)
        {
            double p = values[3] - values[2] - values[0] + values[1];
            double q = values[0] - values[1] - p;
            double r = values[2] - values[0];
            double s = values[1];
            return p * frac * frac * frac + q * frac * frac + r * frac + s;
        }
    }
}
